<!DOCTYPE html>
<html lang="zh-CN">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <title>yylAdmin前后端部署到同一域名 | yylAdmin</title>
    <meta name="generator" content="VuePress 1.8.2">
    <script src="https://cdn.jsdelivr.net/npm/react/umd/react.production.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/react-dom/umd/react-dom.production.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/@babel/standalone/babel.min.js"></script>
    <link rel="alternate" type="application/atom+xml" href="https://skyselang.github.io/yylAdminDoc/yylAdminDoc/atom.xml" title="yylAdmin Atom Feed">
    <link rel="alternate" type="application/json" href="https://skyselang.github.io/yylAdminDoc/yylAdminDoc/feed.json" title="yylAdmin JSON Feed">
    <link rel="alternate" type="application/rss+xml" href="https://skyselang.github.io/yylAdminDoc/yylAdminDoc/rss.xml" title="yylAdmin RSS Feed">
    <link rel="icon" href="/yylAdminDoc/favicon.ico">
    <link rel="icon" href="/yylAdminDoc/assets/icon/chrome-mask-512.png" type="image/png" sizes="512x512">
    <link rel="icon" href="/yylAdminDoc/assets/icon/chrome-mask-192.png" type="image/png" sizes="192x192">
    <link rel="icon" href="/yylAdminDoc/assets/icon/chrome-512.png" type="image/png" sizes="512x512">
    <link rel="icon" href="/yylAdminDoc/assets/icon/chrome-192.png" type="image/png" sizes="192x192">
    <link rel="manifest" href="/yylAdminDoc/manifest.webmanifest" crossorigin="use-credentials">
    <link rel="apple-touch-icon" href="/yylAdminDoc/assets/icon/apple-icon-152.png">
    <meta name="description" content="基于ThinkPHP6和Vue2的极简后台管理系统，只有登录退出、权限管理、日志管理、接口文档与调试等前后台基础功能，简单轻量，开箱即用，前后分离，免费开源">
    <meta property="og:url" content="/yylAdminDoc/course/same-domain-name.html">
    <meta property="og:site_name" content="yylAdmin">
    <meta property="og:title" content="yylAdmin前后端部署到同一域名">
    <meta property="og:type" content="article">
    <meta property="og:locale" content="zh-CN">
    <meta name="twitter:card" content="summary_large_image">
    <meta name="twitter:image:alt" content="yylAdmin">
    <meta property="article:author" content="skyselang">
    <meta name="theme-color" content="#46bd87">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="msapplication-TileImage" content="/yylAdminDoc/assets/icon/ms-icon-144.png">
    <meta name="msapplication-TileColor" content="#ffffff">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, viewport-fit=cover">
    
    <link rel="preload" href="/yylAdminDoc/assets/css/0.styles.7fd1cb05.css" as="style"><link rel="preload" href="/yylAdminDoc/assets/js/app.bf45fc39.js" as="script"><link rel="preload" href="/yylAdminDoc/assets/js/vendors~layout-Layout.3f2f1490.js" as="script"><link rel="preload" href="/yylAdminDoc/assets/js/vendors~layout-Blog~layout-Layout~layout-NotFound.f9603571.js" as="script"><link rel="preload" href="/yylAdminDoc/assets/js/page-yylAdmin前后端部署到同一域名.c7dc032e.js" as="script"><link rel="preload" href="/yylAdminDoc/assets/js/vendors~layout-Blog~layout-Layout~layout-NotFound~layout-Slide.c25e6382.js" as="script"><link rel="prefetch" href="/yylAdminDoc/assets/js/32.e28e3998.js"><link rel="prefetch" href="/yylAdminDoc/assets/js/33.1a898c7a.js"><link rel="prefetch" href="/yylAdminDoc/assets/js/34.1758fbe4.js"><link rel="prefetch" href="/yylAdminDoc/assets/js/35.64cd764c.js"><link rel="prefetch" href="/yylAdminDoc/assets/js/36.cabb40c4.js"><link rel="prefetch" href="/yylAdminDoc/assets/js/37.b3591583.js"><link rel="prefetch" href="/yylAdminDoc/assets/js/layout-Blog.b60ddcb2.js"><link rel="prefetch" href="/yylAdminDoc/assets/js/layout-Layout.1068e31b.js"><link rel="prefetch" href="/yylAdminDoc/assets/js/layout-NotFound.356dd024.js"><link rel="prefetch" href="/yylAdminDoc/assets/js/layout-Slide.66071f13.js"><link rel="prefetch" href="/yylAdminDoc/assets/js/mermaid.35b144d1.js"><link rel="prefetch" href="/yylAdminDoc/assets/js/page-yylAdmin.9e5b2251.js"><link rel="prefetch" href="/yylAdminDoc/assets/js/page-介绍.3c4599e1.js"><link rel="prefetch" href="/yylAdminDoc/assets/js/page-刷新后台权限.aef21536.js"><link rel="prefetch" href="/yylAdminDoc/assets/js/page-基础.c7860453.js"><link rel="prefetch" href="/yylAdminDoc/assets/js/page-安装.3440e73e.js"><link rel="prefetch" href="/yylAdminDoc/assets/js/page-常见问题.580f2b46.js"><link rel="prefetch" href="/yylAdminDoc/assets/js/page-快速生成Crud.71e620a9.js"><link rel="prefetch" href="/yylAdminDoc/assets/js/page-接口文档调试.0177eb25.js"><link rel="prefetch" href="/yylAdminDoc/assets/js/page-教程.76fd8db1.js"><link rel="prefetch" href="/yylAdminDoc/assets/js/page-新增功能.b2daf0ff.js"><link rel="prefetch" href="/yylAdminDoc/assets/js/page-添加前台接口.173092c4.js"><link rel="prefetch" href="/yylAdminDoc/assets/js/page-添加后台接口.b278389e.js"><link rel="prefetch" href="/yylAdminDoc/assets/js/page-添加后台页面.0d94e7c3.js"><link rel="prefetch" href="/yylAdminDoc/assets/js/page-目录.3e02dc49.js"><link rel="prefetch" href="/yylAdminDoc/assets/js/page-跨域问题.2a4b9c14.js"><link rel="prefetch" href="/yylAdminDoc/assets/js/page-配置.688dfa1b.js"><link rel="prefetch" href="/yylAdminDoc/assets/js/page-鸣谢.c6145555.js"><link rel="prefetch" href="/yylAdminDoc/assets/js/vendors~flowchart.f4c04ff1.js"><link rel="prefetch" href="/yylAdminDoc/assets/js/vendors~mermaid.21a65116.js"><link rel="prefetch" href="/yylAdminDoc/assets/js/vendors~photo-swipe.b9318fe8.js"><link rel="prefetch" href="/yylAdminDoc/assets/js/vendors~reveal.3e7400a3.js">
    <link rel="stylesheet" href="/yylAdminDoc/assets/css/0.styles.7fd1cb05.css">
  </head>
  <body>
    <div id="app" data-server-rendered="true"><div class="theme-container has-navbar has-sidebar has-anchor"><header class="navbar"><!----> <div class="content__navbar-start"></div> <button title="Sidebar Button" class="sidebar-button"><span class="icon"></span></button> <a href="/yylAdminDoc/" class="home-link router-link-active"><img src="/yylAdminDoc/logo.svg" alt="yylAdmin" class="logo"> <!----> <span class="site-name can-hide">yylAdmin</span></a> <!----> <div class="content__navbar-center"></div> <div class="links"><button tabindex="-1" aria-hidden="true" class="color-button"><svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg" class="skin-icon"><path d="M224 800c0 9.6 3.2 44.8 6.4 54.4 6.4 48-48 76.8-48 76.8s80 41.6 147.2 0 134.4-134.4
        38.4-195.2c-22.4-12.8-41.6-19.2-57.6-19.2C259.2 716.8 227.2 761.6 224 800zM560 675.2l-32
        51.2c-51.2 51.2-83.2 32-83.2 32 25.6 67.2 0 112-12.8 128 25.6 6.4 51.2 9.6 80 9.6 54.4 0
        102.4-9.6 150.4-32l0 0c3.2 0 3.2-3.2 3.2-3.2 22.4-16 12.8-35.2
        6.4-44.8-9.6-12.8-12.8-25.6-12.8-41.6 0-54.4 60.8-99.2 137.6-99.2 6.4 0 12.8 0 22.4
        0 12.8 0 38.4 9.6 48-25.6 0-3.2 0-3.2 3.2-6.4 0-3.2 3.2-6.4 3.2-6.4 6.4-16 6.4-16 6.4-19.2
        9.6-35.2 16-73.6 16-115.2 0-105.6-41.6-198.4-108.8-268.8C704 396.8 560 675.2 560 675.2zM224
        419.2c0-28.8 22.4-51.2 51.2-51.2 28.8 0 51.2 22.4 51.2 51.2 0 28.8-22.4 51.2-51.2 51.2C246.4
        470.4 224 448 224 419.2zM320 284.8c0-22.4 19.2-41.6 41.6-41.6 22.4 0 41.6 19.2 41.6 41.6 0
        22.4-19.2 41.6-41.6 41.6C339.2 326.4 320 307.2 320 284.8zM457.6 208c0-12.8 12.8-25.6 25.6-25.6
        12.8 0 25.6 12.8 25.6 25.6 0 12.8-12.8 25.6-25.6 25.6C470.4 233.6 457.6 220.8 457.6 208zM128
        505.6C128 592 153.6 672 201.6 736c28.8-60.8 112-60.8 124.8-60.8-16-51.2 16-99.2
        16-99.2l316.8-422.4c-48-19.2-99.2-32-150.4-32C297.6 118.4 128 291.2 128 505.6zM764.8
        86.4c-22.4 19.2-390.4 518.4-390.4 518.4-22.4 28.8-12.8 76.8 22.4 99.2l9.6 6.4c35.2 22.4
        80 12.8 99.2-25.6 0 0 6.4-12.8 9.6-19.2 54.4-105.6 275.2-524.8 288-553.6
        6.4-19.2-3.2-32-19.2-32C777.6 76.8 771.2 80 764.8 86.4z"></path></svg> <div class="color-picker-menu" style="display:none;"><div class="theme-options"><ul class="themecolor-select"><label for="themecolor-select">主题色:</label> <li><span class="default-theme"></span></li> </ul> <div class="darkmode-toggle"><label for="darkmode-toggle" class="desc">主题模式:</label> <div class="darkmode-switch"><div class="item day"><svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg" class="icon light-icon"><path d="M512 256a42.667 42.667 0 0 0 42.667-42.667V128a42.667 42.667 0 0 0-85.334 0v85.333A42.667 42.667 0 0 0 512 256zm384 213.333h-85.333a42.667 42.667 0 0 0 0 85.334H896a42.667 42.667 0 0 0 0-85.334zM256 512a42.667 42.667 0 0 0-42.667-42.667H128a42.667 42.667 0 0 0 0 85.334h85.333A42.667 42.667 0 0 0 256 512zm9.387-298.667a42.667 42.667 0 0 0-59.307 62.72l61.44 59.307a42.667 42.667 0 0 0 31.147 11.947 42.667 42.667 0 0 0 30.72-13.227 42.667 42.667 0 0 0 0-60.16zm459.946 133.974a42.667 42.667 0 0 0 29.44-11.947l61.44-59.307a42.667 42.667 0 0 0-57.6-62.72l-61.44 60.587a42.667 42.667 0 0 0 0 60.16 42.667 42.667 0 0 0 28.16 13.227zM512 768a42.667 42.667 0 0 0-42.667 42.667V896a42.667 42.667 0 0 0 85.334 0v-85.333A42.667 42.667 0 0 0 512 768zm244.48-79.36a42.667 42.667 0 0 0-59.307 61.44l61.44 60.587a42.667 42.667 0 0 0 29.44 11.946 42.667 42.667 0 0 0 30.72-12.8 42.667 42.667 0 0 0 0-60.586zm-488.96 0-61.44 59.307a42.667 42.667 0 0 0 0 60.586 42.667 42.667 0 0 0 30.72 12.8 42.667 42.667 0 0 0 28.587-10.666l61.44-59.307a42.667 42.667 0 0 0-59.307-61.44zM512 341.333A170.667 170.667 0 1 0 682.667 512 170.667 170.667 0 0 0 512 341.333z" fill="currentColor"></path></svg></div> <div class="item auto active"><svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg" class="icon auto-icon"><path d="M460.864 539.072H564.8L510.592 376l-49.728 163.072zM872 362.368V149.504H659.648L510.528 0l-149.12 149.504H149.12v212.928L0 511.872l149.12 149.504v212.928h212.352l149.12 149.504 149.12-149.504h212.352V661.376l149.12-149.504L872 362.368zM614.464 693.12l-31.616-90.624H438.272l-31.616 90.624h-85.888l144.576-407.68h90.368l144.576 407.68h-85.824zm0 0" fill="currentColor"></path></svg></div> <div class="item night"><svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg" class="icon dark-icon"><path d="M935.539 630.402c-11.43-11.432-28.674-14.739-43.531-8.354-46.734 20.103-96.363 30.297-147.508 30.297-99.59 0-193.221-38.784-263.64-109.203-108.637-108.637-139.61-270.022-78.908-411.148a39.497 39.497 0 0 0-51.886-51.887c-52.637 22.64-100.017 54.81-140.826 95.616-85.346 85.346-132.346 198.821-132.346 319.52 0 120.7 47.001 234.172 132.347 319.519S408.063 947.11 528.76 947.11c120.7 0 234.172-47.003 319.52-132.351 40.809-40.81 72.978-88.19 95.616-140.826a39.497 39.497 0 0 0-8.356-43.532z" fill="currentColor"></path></svg></div></div> <!----></div></div></div></button> <div class="search-box"><input aria-label="Search" autocomplete="off" spellcheck="false" value=""> <!----></div> <nav class="nav-links can-hide"><div class="nav-item"><a href="/yylAdminDoc/guide/" class="nav-link"><i class="iconfont icon-creative"></i>
  指南
</a></div><div class="nav-item"><a href="/yylAdminDoc/config/" class="nav-link"><i class="iconfont icon-config"></i>
  配置
</a></div><div class="nav-item"><a href="/yylAdminDoc/use/" class="nav-link"><i class="iconfont icon-edit"></i>
  使用
</a></div><div class="nav-item"><a href="/yylAdminDoc/course/" class="nav-link router-link-active active"><i class="iconfont icon-blog"></i>
  教程
</a></div><div class="nav-item"><a href="/yylAdminDoc/fqa/" class="nav-link"><i class="iconfont icon-question"></i>
  常见问题
</a></div><div class="nav-item"><a href="https://gitee.com/skyselang/yylAdmin.git" target="_blank" rel="noopener noreferrer" class="nav-link external"><i class="iconfont icon-gitee"></i>
  Gitee
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></div></nav> <!----> <a rel="noopener noreferrer" href="https://github.com/skyselang/yylAdmin.git" target="_blank" class="repo-link can-hide">
  GitHub
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a> <!----> <div class="content__navbar-end"></div></div></header> <div class="sidebar-mask"></div> <aside class="sidebar"><!----> <!----> <div class="content__sidebar-top"></div> <nav class="sidebar-nav-links"><div class="nav-item"><a href="/yylAdminDoc/guide/" class="nav-link"><i class="iconfont icon-creative"></i>
  指南
</a></div><div class="nav-item"><a href="/yylAdminDoc/config/" class="nav-link"><i class="iconfont icon-config"></i>
  配置
</a></div><div class="nav-item"><a href="/yylAdminDoc/use/" class="nav-link"><i class="iconfont icon-edit"></i>
  使用
</a></div><div class="nav-item"><a href="/yylAdminDoc/course/" class="nav-link router-link-active active"><i class="iconfont icon-blog"></i>
  教程
</a></div><div class="nav-item"><a href="/yylAdminDoc/fqa/" class="nav-link"><i class="iconfont icon-question"></i>
  常见问题
</a></div><div class="nav-item"><a href="https://gitee.com/skyselang/yylAdmin.git" target="_blank" rel="noopener noreferrer" class="nav-link external"><i class="iconfont icon-gitee"></i>
  Gitee
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></div> <a rel="noopener noreferrer" href="https://github.com/skyselang/yylAdmin.git" target="_blank" class="repo-link">
  GitHub
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></nav> <!----> <div class="content__sidebar-center"></div> <ul class="sidebar-links"><li><a href="/yylAdminDoc/course/" aria-current="page" class="sidebar-link"><i class="iconfont icon-blog"></i>教程</a></li></ul> <!----> <div class="content__sidebar-bottom"></div> <!----></aside> <main class="page"><nav class="breadcrumb"><ol vocab="https://schema.org/" typeof="BreadcrumbList"><li property="itemListElement" typeof="ListItem"><a href="/yylAdminDoc/course/" property="item" typeof="WebPage" class="router-link-active"><i class="iconfont icon-blog"></i> <span property="name">教程</span></a> <meta property="position" content="1"></li><li property="itemListElement" typeof="ListItem" class="is-active"><a href="/yylAdminDoc/course/same-domain-name/" aria-current="page" property="item" typeof="WebPage" class="router-link-exact-active router-link-active"><i class="iconfont icon-blog"></i> <span property="name">yylAdmin前后端部署到同一域名</span></a> <meta property="position" content="2"></li></ol></nav> <!----> <div class="content__page-top"></div> <div vocab="https://schema.org/" typeof="Article" class="page-title"><h1><i class="iconfont icon-blog"></i> <span property="headline">yylAdmin前后端部署到同一域名</span></h1> <div class="page-info"><!----> <span aria-label="作者🖊" data-balloon-pos="down"><svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg" class="icon author-icon"><path d="M649.6 633.6c86.4-48 147.2-144 147.2-249.6 0-160-128-288-288-288s-288 128-288 288c0 108.8 57.6 201.6 147.2 249.6-121.6 48-214.4 153.6-240 288-3.2 9.6 0 19.2 6.4 25.6 3.2 9.6 12.8 12.8 22.4 12.8h704c9.6 0 19.2-3.2 25.6-12.8 6.4-6.4 9.6-16 6.4-25.6-25.6-134.4-121.6-240-243.2-288z" fill="currentColor"></path></svg> <span property="author">skyselang</span></span><!----><span aria-label="写作日期📅" data-balloon-pos="down" class="time-info"><svg viewBox="0 0 1030 1024" xmlns="http://www.w3.org/2000/svg" class="icon calendar-icon"><path d="M716.4 110.137c0-18.753-14.72-33.473-33.472-33.473-18.753 0-33.473 14.72-33.473 33.473v33.473h66.993v-33.473zm-334.87 0c0-18.753-14.72-33.473-33.473-33.473s-33.52 14.72-33.52 33.473v33.473h66.993v-33.473zm468.81 33.52H716.4v100.465c0 18.753-14.72 33.473-33.472 33.473a33.145 33.145 0 0 1-33.473-33.473V143.657H381.53v100.465c0 18.753-14.72 33.473-33.473 33.473a33.145 33.145 0 0 1-33.473-33.473V143.657H180.6A134.314 134.314 0 0 0 46.66 277.595v535.756A134.314 134.314 0 0 0 180.6 947.289h669.74a134.36 134.36 0 0 0 133.94-133.938V277.595a134.314 134.314 0 0 0-133.94-133.938zm33.473 267.877H147.126a33.145 33.145 0 0 1-33.473-33.473c0-18.752 14.72-33.473 33.473-33.473h736.687c18.752 0 33.472 14.72 33.472 33.473a33.145 33.145 0 0 1-33.472 33.473z" fill="currentColor"></path></svg> <span property="datePublished">2021-5-11</span></span><!----><!----><span aria-label="字数🔠" data-balloon-pos="down" class="words-info"><svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg" class="icon word-icon"><path d="M518.217 432.64V73.143A73.143 73.143 0 0 1 603.43 1.097a512 512 0 0 1 419.474 419.474 73.143 73.143 0 0 1-72.046 85.212H591.36a73.143 73.143 0 0 1-73.143-73.143z" fill="currentColor"></path> <path d="M493.714 566.857h340.297a73.143 73.143 0 0 1 73.143 85.577A457.143 457.143 0 1 1 371.566 117.76a73.143 73.143 0 0 1 85.577 73.143v339.383a36.571 36.571 0 0 0 36.571 36.571z" fill="currentColor"></path></svg> <span>约 521 字</span> <meta property="wordCount" content="521"></span><span aria-label="阅读时间⌛" data-balloon-pos="down" class="reading-time-info"><svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg" class="icon timer-icon"><path d="M799.387 122.15c4.402-2.978 7.38-7.897 7.38-13.463v-1.165c0-8.933-7.38-16.312-16.312-16.312H256.33c-8.933 0-16.311 7.38-16.311 16.312v1.165c0 5.825 2.977 10.874 7.637 13.592 4.143 194.44 97.22 354.963 220.201 392.763-122.204 37.542-214.893 196.511-220.2 389.397-4.661 5.049-7.638 11.651-7.638 19.03v5.825h566.49v-5.825c0-7.379-2.849-13.981-7.509-18.9-5.049-193.016-97.867-351.985-220.2-389.527 123.24-37.67 216.446-198.453 220.588-392.892zM531.16 450.445v352.632c117.674 1.553 211.787 40.778 211.787 88.676H304.097c0-48.286 95.149-87.382 213.728-88.676V450.445c-93.077-3.107-167.901-81.297-167.901-177.093 0-8.803 6.99-15.793 15.793-15.793 8.803 0 15.794 6.99 15.794 15.793 0 80.261 63.69 145.635 142.01 145.635s142.011-65.374 142.011-145.635c0-8.803 6.99-15.793 15.794-15.793s15.793 6.99 15.793 15.793c0 95.019-73.789 172.82-165.96 177.093z" fill="currentColor"></path></svg> <span>大约 2 分钟</span> <meta property="timeRequired" content="PT2M"></span></div> <!----> <hr></div> <div class="anchor-place-holder"><aside id="anchor"><div class="anchor-wrapper"><ul class="anchor-list"><li class="anchor"><a href="/yylAdminDoc/course/same-domain-name/#一-默认打包路径" class="anchor-link heading3"><div>一，默认打包路径</div></a></li><li class="anchor"><a href="/yylAdminDoc/course/same-domain-name/#二-自定义打包路径" class="anchor-link heading3"><div>二，自定义打包路径</div></a></li></ul></div></aside></div> <!----> <div class="content__content-top"></div> <div class="theme-default-content content__default"><p>前端和后端部署在同一个域名下，可以解决跨域问题，可以通过下面两种方法设置。</p> <blockquote><p>当然前后端分开部署正常情况下也不会有跨域问题，yylAdmin已经做了跨域处理</p></blockquote> <h3 id="一-默认打包路径"><a href="#一-默认打包路径" class="header-anchor">#</a> 一，默认打包路径</h3> <p>1、把 yylAdminWeb/.env.production.domain 文件重命名成 .env.production.local，<br>
2、运行打包命令 cnpm run build:prod，<br>
3、把 yylAdminWeb/admin 文件夹复制到 yylAdmin/public 文件夹下 yylAdmin/public/admin<br>
4、部署yylAdmin到服务器上，浏览器打开： 你的域名/admin/</p> <h3 id="二-自定义打包路径"><a href="#二-自定义打包路径" class="header-anchor">#</a> 二，自定义打包路径</h3> <h4 id="设置前端环境接口地址"><a href="#设置前端环境接口地址" class="header-anchor">#</a> 设置前端环境接口地址</h4> <p>把.env.production环境文件中的接口地址设置为空：VUE_APP_BASE_API = ''</p> <blockquote><p>可以根据打包环境修改对应文件，如果打包测试环境，就在.env.staging中修改<br> <img src="/yylAdminDoc/image/course/same-domain-name/1-env-prod.png" alt=""></p></blockquote> <h4 id="配置路径和打包目录、打包"><a href="#配置路径和打包目录、打包" class="header-anchor">#</a> 配置路径和打包目录、打包</h4> <p>把.vue.config.js配置文件中的公共路径publicPath设置为/admin/,打包路径outputDir设置为admin<br>
运行打包命令：cnpm run build:prod</p> <blockquote><p>这两个路径名称可以自定义，但是名称必须一样；如果修改的是测试环境文件，运行：cnpm run build:stage
<img src="/yylAdminDoc/image/course/same-domain-name/2-vue-config-js.png" alt=""></p></blockquote> <h4 id="复制打包目录到yyladmin-public文件夹下"><a href="#复制打包目录到yyladmin-public文件夹下" class="header-anchor">#</a> 复制打包目录到yylAdmin/public文件夹下</h4> <p>把前面打包后生成的目录admin复制到后端public文件下</p> <blockquote><p>就是把yylAdminWeb/admin文件夹复制到yylAdmin/public文件夹下：yylAdmin/public/admin
<img src="/yylAdminDoc/image/course/same-domain-name/3-copy-yyladmin-public.png" alt=""></p></blockquote> <h4 id="本地测试一下是否能访问"><a href="#本地测试一下是否能访问" class="header-anchor">#</a> 本地测试一下是否能访问</h4> <p>http://localhost:9526/admin/</p> <blockquote><p>http://localhost:9526是后端地址，/admin/是前面设置的公共路径
<img src="/yylAdminDoc/image/course/same-domain-name/4-localhost-open.png" alt=""></p></blockquote> <h4 id="部署yyladmin到服务器上、访问"><a href="#部署yyladmin到服务器上、访问" class="header-anchor">#</a> 部署yylAdmin到服务器上、访问</h4> <p>你的域名/admin/</p> <blockquote><p>输入部署后端域名，再加上公共路径就可以访问了
<img src="/yylAdminDoc/image/course/same-domain-name/5-pro-open.png" alt=""></p></blockquote> <h4 id="前台前端"><a href="#前台前端" class="header-anchor">#</a> 前台前端</h4> <p>同样，可以把前台前端（web、h5）、后台前端（yylAdminWeb）与 后端（yylAdmin）放到同一个域名下，这样也不会有跨域问题</p></div> <!----> <div class="content__content-bottom"></div> <footer class="page-meta"><div class="edit-link"><svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg" class="icon edit-icon"><path d="M117.953 696.992 64.306 959.696l265.931-49.336 450.204-452.505-212.284-213.376-450.204 452.513zm496.384-296.326L219.039 797.993l-46.108-46.34L568.233 354.33l46.104 46.335zm345.357-122.99-114.45 115.04-212.288-213.377 114.45-115.035 212.288 213.371zm0 0" fill="currentColor"></path></svg> <a href="https://github.com/skyselang/yylAdmin.git/edit/main/course/same-domain-name.md" target="_blank" rel="noopener noreferrer">编辑此页</a></div> <div class="meta-item update-time"><span class="label">上次编辑于:</span> <span class="info">2021年5月27日 18:31</span></div> <div class="meta-item contributors"><span class="label">贡献者: </span> <span class="info"><span title="email: 215817969@qq.com" class="contributor">
          skyselang
        </span> <!----></span></div></footer> <!----> <!----> <!----> <div class="content__page-bottom"></div></main> <footer class="footer-wrapper"><!----> <div class="footer"><div>感谢每一位支持的coder | 点个Star吧 <a href="https://gitee.com/skyselang/yylAdmin" target="_blank"><i class="iconfont icon-gitee"></i>Gitee</a><a href="https://github.com/skyselang/yylAdmin" target="_blank"><i class="iconfont icon-github"></i>GitHub</a></div></div> <div class="copyright">Copyright © 2021 skyselang</div></footer></div><div class="global-ui"><!----><!----><div id="pwa-install"><!----> <div id="install-modal-wrapper" style="display:none;"><div class="background"></div> <div class="install-modal"><div class="header"><button aria-label="Close" class="close-button"><svg width="23" height="22" xmlns="http://www.w3.org/2000/svg" class="icon close-icon"><path fill-rule="evenodd" clip-rule="evenodd" d="M1.12.358a1.224 1.224 0 011.729 0l8.92 8.914L20.686.358a1.224 1.224 0 011.73 1.728L13.497 11l8.92 8.913a1.222 1.222 0 11-1.73 1.729l-8.919-8.913-8.92 8.913a1.224 1.224 0 01-1.729-1.729L10.04 11l-8.92-8.914a1.222 1.222 0 010-1.728z" fill="currentColor"></path></svg></button> <div class="logo"><!----> <div class="title"><h1></h1> <p class="desc">该应用可以安装在您的 PC 或移动设备上。这将使该 Web 应用程序外观和行为与其他应用程序相同。它将在出现在应用程序列表中，并可以固定到主屏幕，开始菜单或任务栏。此 Web 应用程序还将能够与其他应用程序和您的操作系统安全地进行交互。</p></div></div></div> <div class="content"><div class="highlight"><!----> <!----></div> <div class="description"><h3>详情</h3> <p></p></div></div> <div class="button-wrapper"><button class="install-button">
        安装 <span></span></button> <button class="cancel-button">
        取消
      </button></div></div></div></div><div tabindex="-1" role="dialog" aria-hidden="true" class="pswp"><div class="pswp__bg"></div> <div class="pswp__scroll-wrap"><div class="pswp__container"><div class="pswp__item"></div> <div class="pswp__item"></div> <div class="pswp__item"></div></div> <div class="pswp__ui pswp__ui--hidden"><div class="pswp__top-bar"><div class="pswp__counter"></div> <button title="Close (Esc)" class="pswp__button pswp__button--close"></button> <button title="Share" class="pswp__button pswp__button--share"></button> <button title="Toggle fullscreen" class="pswp__button pswp__button--fs"></button> <button title="Zoom in/out" class="pswp__button pswp__button--zoom"></button> <div class="pswp__preloader"><div class="pswp__preloader__icn"><div class="pswp__preloader__cut"><div class="pswp__preloader__donut"></div></div></div></div></div> <div class="pswp__share-modal pswp__share-modal--hidden pswp__single-tap"><div class="pswp__share-tooltip"></div></div> <button title="Previous (arrow left)" class="pswp__button pswp__button--arrow--left"></button> <button title="Next (arrow right)" class="pswp__button pswp__button--arrow--right"></button> <div class="pswp__caption"><div class="pswp__caption__center"></div></div></div></div></div></div></div>
    <script src="/yylAdminDoc/assets/js/app.bf45fc39.js" defer></script><script src="/yylAdminDoc/assets/js/vendors~layout-Layout.3f2f1490.js" defer></script><script src="/yylAdminDoc/assets/js/vendors~layout-Blog~layout-Layout~layout-NotFound.f9603571.js" defer></script><script src="/yylAdminDoc/assets/js/page-yylAdmin前后端部署到同一域名.c7dc032e.js" defer></script><script src="/yylAdminDoc/assets/js/vendors~layout-Blog~layout-Layout~layout-NotFound~layout-Slide.c25e6382.js" defer></script>
  </body>
</html>
